package net.sk.china.city.domain.dto.activity;

import net.sk.china.city.domain.ArActivity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static net.sk.china.city.utils.JsonStrCovertUtil.strToObjArray;

@Data
public class ActivityInfoDTO {
    @ApiModelProperty("主键")
    private Long pkId;

    @ApiModelProperty("活动名")
    private String activityName;

    @ApiModelProperty("封面URL")
    private String cover;

    @ApiModelProperty("活动开始时间")
    private LocalDateTime startDatetime;

    @ApiModelProperty("活动结束时间")
    private LocalDateTime endDatetime;

    @ApiModelProperty("报名截止时间")
    private LocalDateTime signEndDatetime;

    @ApiModelProperty("可报名人数")
    private Long maxCount;

    @ApiModelProperty("条件说明")
    private String conditionRequire;

    @ApiModelProperty("活动介绍")
    private String description;

    @ApiModelProperty("活动地点")
    private String address;

    @ApiModelProperty("活动状态：0:报名中，1:已截止报名，2:已结束")
    private Long status;

    @ApiModelProperty("岗位，对象数组")
    private List<Job> job;

    @ApiModelProperty("场次，对象数组")
    private List<Session> session;

    @ApiModelProperty("特点，对象数组")
    private List<Feature> feature;

    @ApiModelProperty("福利，对象数组")
    private List<Welfare> welfare;

    @ApiModelProperty("主办方，对象数组")
    private List<Organizer> organizer;

    @ApiModelProperty("工时(积分)")
    private BigDecimal workHour;

    @ApiModelProperty("报名人数")
    private Integer signedCount;

    public static ActivityInfoDTO from(ArActivity activity) {
        ActivityInfoDTO activityInfoDTO = new ActivityInfoDTO();
        activityInfoDTO.setPkId(activity.getPkId());
        activityInfoDTO.setActivityName(activity.getActivityName());
        activityInfoDTO.setCover(activity.getCover());
        activityInfoDTO.setStartDatetime(activity.getStartDatetime());
        activityInfoDTO.setEndDatetime(activity.getEndDatetime());
        activityInfoDTO.setSignEndDatetime(activity.getSignEndDatetime());
        activityInfoDTO.setMaxCount(activity.getMaxCount());
        activityInfoDTO.setConditionRequire(activity.getConditionRequire());
        activityInfoDTO.setDescription(activity.getDescription());
        activityInfoDTO.setAddress(activity.getAddress());
        activityInfoDTO.setStatus(activity.getStatus());
        activityInfoDTO.setJob(activity.getJobList());
        List<Session> sessionList = strToObjArray(activity.getSession(), Session.class);
        activityInfoDTO.setSession(sessionList);
        List<Feature> featureList = strToObjArray(activity.getFeature(), Feature.class);
        activityInfoDTO.setFeature(featureList);
        List<Welfare> welfareList = strToObjArray(activity.getWelfare(), Welfare.class);
        activityInfoDTO.setWelfare(welfareList);
        List<Organizer> organizerList = strToObjArray(activity.getOrganizer(), Organizer.class);
        activityInfoDTO.setOrganizer(organizerList);
        activityInfoDTO.setWorkHour(activity.getWorkHour());
        activityInfoDTO.setSignedCount(activity.getSignedCount());
        return activityInfoDTO;
    }
}
